package me.zhengjie.minbearwcs.entity.PO.wcs.mission.type;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.minbearwcs.entity.PO.wcs.mission.status.*;

import java.lang.reflect.Method;

@Slf4j
public enum MissionType {
    INBOUND_5_OR_6_FLOOR(InboundMissionFor5Or6FloorStatus.class),
    INBOUND_3_OR_4_FLOOR(InboundMissionFor3Or4FloorStatus.class),
    OUTBOUND_STOCK_UP(OutboundStockUpMissionStatus.class),
    OUTBOUND_WHOLE_PALLET(OutboundWholePalletMissionStatus.class),
    OUTBOUND_SORT(OutboundSortMissionStatus.class),
    OUTBOUND_AFTER_SORT(OutboundAfterSortMissionStatus.class),
    OUTBOUND_SORT_EXCEPTION(OutboundSortExceptionStatus.class),
    SHIFTING(ShiftingMissionStatus.class),
    REWORK(ReworkMissionStatus.class),
    REWORK_SHIFTING(ReworkShiftingMissionStatus.class),;


    MissionType(Class<? extends MissionStatus> missionStatus) {
        this.missionStatus = missionStatus;
    }

    private final Class<? extends MissionStatus> missionStatus;

    public MissionStatus getMissionStatus(String statusStr)  {
        try {
            Method method = missionStatus.getDeclaredMethod("valueOf", String.class);
            return (MissionStatus) method.invoke(null,statusStr);
        }catch (Exception e){
            log.error("无法获取任务状态：{} ",statusStr,e);
            return null;
        }

    }
}
